#include "game.h"
#include "buttons.h"


const int BulletAmount = 3;

struct PlayerShip
{
	Vector2D thePosition;
	Vector2D theVelocity;

	bool isActive;

	int health;

	Vector2D BulletPos[BulletAmount];
	Vector2D BulletVel;
	bool BulletActive[BulletAmount];
	RectangularGameObject BulletShape[BulletAmount];

	RectangularGameObject theShip;
	RectangularGameObject theGun;
};

struct Blockers
{
	Vector2D thePosition;

	RectangularGameObject thePieces[6][4];
	bool activePieces[6][4];
};

struct enemyShip
{
	Vector2D thePosition;
	Vector2D theVelocity;
	Vector2D enemySize;

	int row;
	int column;

	bool isActive;

	Image theShipImage;
};

class EnemyCollection
{
	enemyShip theEnemy[40];

	bool isActive;
	
	Vector2D initialPosition;
	Vector2D incrementPosition;

	bool changeDirection;
	bool movingRight;

	bool landed;

	int timeToFire;

	Vector2D BulletPos[BulletAmount];
	bool BulletActive[BulletAmount];
	RectangularGameObject BulletShape[BulletAmount];

public:

	EnemyCollection();
	void update(Vector2D BulletPos[3], double &timeToMove);
	void draw();
	bool checkLanded();
};

class SpaceInvadersGame : public Game
{
	Button startButton;
	Button endButton;
	Button menuButton;

	int timer;
	int score;
	int highScore;

	bool Won;

	currentState theState;

	double timeToMove;
	double timeToNextMove;

	void theGameLoop();

	RectangularGameObject blockers[15][15][4];

	PlayerShip thePlayer;

	EnemyCollection theEnemies;


public:

	void GameInit();
	void GameMain();
	void GameShutdown();

	GameResult theResult;

};

Game* GetSpaceInvadersGame();